I have two regex that work separately: ^[\x20-\x7E]*$ and \S(.*\S
But I don't get how to combine the two so it will match them both.
I tried (^[\x20-\x7E]*$)*?(\S(.*\S)?) but it didn't work.
I used this in input tag with pattern="(^[\x20-\x7E]*$)*?(\S(.*\S)?)"
Combine the two regexes with the pipe symbol. It is the same as the logical OR. Here's a code snippet demonstrating how to use this.
import re
regex_list = ["^[\x20-\x7E]$", "\S(.*\S)"]
regex = '|'.join(regex_list)
print(regex) # ^[ -~]$|\S(.*\S)
print(re.search(regex, "C")) #matches first pattern
print(re.search(regex, "CAT CAT")) #matches second pattern
print(re.search(regex, " 3 ")) #matches neither pattern